package com.sjz.bookmark.setting;

import cn.hutool.core.util.StrUtil;

import javax.swing.*;


public class GeneralSettings {
    private JTextField mysqlHost;
    private JTextField mysqlPort;
    private JTextField mysqlUser;
    private JTextField mysqlPassword;
    private JTextField mysqlDb;

    private JLabel projectNameLabal;
    private JTextField projectIdLabal;
    private JTextField syncProjectId;
    private JTextArea remarkLabel;
    private JCheckBox showLogCheckBox;
    private JCheckBox useMysqlCheckBox;

    public GeneralSettings(JTextField mysqlHost, JTextField mysqlPort, JTextField mysqlUser,
                           JTextField mysqlPassword,JTextField mysqlDb,
                           JLabel projectNameLabal, JTextField projectIdLabal,
                           JTextField syncProjectId,JTextArea remarkLabel,
                           JCheckBox showLogCheckBox,JCheckBox useMysqlCheckBox) {
        this.mysqlHost = mysqlHost;
        this.mysqlPort = mysqlPort;
        this.mysqlUser = mysqlUser;
        this.mysqlPassword = mysqlPassword;
        this.mysqlDb = mysqlDb;
        this.projectNameLabal = projectNameLabal;
        this.projectIdLabal = projectIdLabal;
        this.syncProjectId = syncProjectId;
        this.remarkLabel = remarkLabel;
        this.showLogCheckBox = showLogCheckBox;
        this.useMysqlCheckBox = useMysqlCheckBox;
    }

    protected void initGeneralSettings() {
        GlobalSettings globalSettings = GlobalSettings.getInstance();
        mysqlHost.setText(globalSettings.getMysqlHost());
        mysqlPort.setText(globalSettings.getMysqlPort());
        mysqlUser.setText(globalSettings.getMysqlUser());
        mysqlPassword.setText(globalSettings.getMysqlPassword());
        mysqlDb.setText(globalSettings.getMysqlDb());
        showLogCheckBox.setSelected(StrUtil.equals(globalSettings.getShowLogCheckBox(),"true"));
        useMysqlCheckBox.setSelected(StrUtil.equals(globalSettings.getUseMysqlCheckBox(),"true"));
        remarkLabel.setRows(5);
        remarkLabel.setText("这是一个书签插件,用了都说好  \n" +
                "特别适合有多台电脑或者多项目的人使用 \n" +
                "1,无需任何配置, 打开就能用 \n" +
                "2,解决idea自带书签,无法同步问题 \n" +
                "3,解决idea自带书签,无法分组问题 \n" +
                "4,我会尽量保持数据安全,每天都本地备份 \n" +
                "5,可以放心的记录插件,不用担心丢失问题 \n" +
                "6,如果遇到数据丢失,请联系我 qq 1287592384 \n"+
                "同步仅需一步,在设置中复制项目id\n"+
                        "粘贴到另一个电脑即可\n"+
                "mysql(联网)和sqlite(本地)都可以\n" +
                "推荐mysql(联网使用,便于同步)\n");

    }
}
